var HTTP_READYSTATE_UNINITIALIZED = 0;
var HTTP_READYSTATE_OPEN = 1;
var HTTP_READYSTATE_SENT = 2;
var HTTP_READYSTATE_RECEIVING = 3;
var HTTP_READYSTATE_LOADED = 4;
var HTTP_STATUS_OK = 200;

function createRequest()
{
    var request = null;
    try
    {
        request = new XMLHttpRequest();
    }
    catch(trymicrosoft)
    {
        try
        {
            request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(othermicrosoft)
        {
            try
            {
                request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(failed)
            {
                request = null;
            }
        }
    }

    if (request == null) {
        alert("Error creating the XMLHttpRequest object!");
    }
    else
    {
        return(request);
    }
}

function sendHttpRequest(request, callbackFunction, url, postData)
{
    var async_request = false;
    if (callbackFunction != null)
    {
        request.onreadystatechange = callbackFunction;
        async_request = true;
    }
    request.open("POST", url, async_request);
    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var response = request.send(postData);
    if (async_request == false) {
        return(response);
    }
    else
    {
        return(true);
    }
}